package cn.maizi.shardingdemo.mapper;

import cn.maizi.shardingdemo.domain.OrderInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface OrderMapper {
    //新增订单
    @Insert("INSERT INTO order(order_id,user_id, product_name, COUNT) VALUES(#{order_id},#{user_id}, #{product_name}, #{count})")
    int insertOrder(@Param("order_id") long order_id,@Param("user_id") int user_id, @Param("product_name") String product_name, @Param("count") int count);

    @Insert("INSERT INTO order(user_id, product_name, COUNT) VALUES(#{user_id}, #{product_name}, #{count})")
    int insertOrderBySNOWFLAKE(@Param("user_id") int user_id, @Param("product_name") String product_name, @Param("count") int count);

    //根据ID集合查询订单数据
//    @Select("select * from order p where p.order_id in <foreach collection='orderIds' item='id' open='(' separator = ',' close=')'>#{id}</foreach>")
    List<OrderInfo> findOrderByIds(@Param("orderIds") List<Long> orderIds);

}
